"""
@author: wy
@file: 11.py
@time: 2023/12/7 19:06
"""
import re

#11、使用python读取/etc/ssh/sshd_config文件，读取它的前5行
#    过滤掉以#号开头的行和空行输出
import re
# filename='a.txt'
filename='/etc/ssh/sshd_config'
with open(filename) as fp:
  for i in range(5):
    data1=fp.readline()
    grep = re.search(r'^[^#].+', data1)
    try:
      print(grep.group())
    except:
      pass


